
# 使用快慢指针
# 如果存在环，快的一定会追上慢的


class Solution:

    def hasCycle(self, head):
        slow = fast = head
        while fast and fast.next:
            slow = slow.next
            fast = fast.next.next

            if fast is slow:
                return True
        # 访问到链表尾了
        return False

